package com.eyaomall.wxmall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eyaomall.wxmall.model.po.Area;
import com.eyaomall.wxmall.service.AreaService;
import com.eyaomall.wxmall.dao.AreaDao;

@Service
public class AreaServiceImpl implements AreaService {

	@Autowired
	private AreaDao areaDao;

	
	/**
	 * 获取所有的区域数据
	 */
	@SuppressWarnings("unchecked")
	public List<Area> getAreas() {

		return areaDao.list("selectArea", null);
	}

	/**
	 * 根据区域类别key获取区域列表
	 */
	@SuppressWarnings("unchecked")
	public List<Area> getAreaByAreaKey(String areaKey) {
		Area area = new Area();
		area.setAreaKey(areaKey);

		return areaDao.list("selectArea", area);
	}

	/**
	 * 根据ID获取区域信息
	 */
	public Area getAreaByID(int id) {
		Area area = new Area();
		area.setId(id);

		return (Area) areaDao.query("selectArea", area);
	}

	/**
	 * 根据根据父类ID和区域类别可以查询区域列表
	 */
	@SuppressWarnings("unchecked")
	public List<Area> getAreaByAreaKeyAndParentID(String areaKey, int parentId) {
		Area area = new Area();
		area.setParentId(parentId);
		area.setAreaKey(areaKey);

		return areaDao.list("selectArea", area);
	}
}
